<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">

    <ui:define name="content">
        <h1>Branch Add Service Package</h1>
        <h:form>
            <p:panel id="panel" header="Change Branch Info">
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages />
                <h:panelGrid columns="1" cellpadding="10">
                    <h:outputLabel for="branchname" style="font-weight: bold" value="Branch name: #{stakeholderManagerBean.selectedBranch.name}" />

                    <h:outputLabel for="blank" style="font-weight: bold" value="Current service package"/>
                    <p:dataTable var="packagePurchased" value="#{stakeholderManagerBean.currentServicePackage}">
                        <p:column headerText="Name">
                            <h:outputText value="#{packagePurchased.servicePackage.name}" />
                        </p:column>

                        <p:column headerText="Description">
                            <h:outputText value="#{packagePurchased.servicePackage.description}" />
                        </p:column>

                        <p:column headerText="Price">
                            <h:outputText value="#{packagePurchased.price}" />
                        </p:column>

                        <p:column headerText="Date Begin">
                            <h:outputText value="#{stakeholderManagerBean.getFormatDate(packagePurchased.datePurchased)}" />
                        </p:column>
                        <p:column headerText="Date Expired">
                            <h:outputText value="#{stakeholderManagerBean.getFormatDate(packagePurchased.dateExpired)}" />
                        </p:column>
                    </p:dataTable>

                    <h:outputLabel for="blank" style="font-weight: bold" value="Service package purchased in future"/>
                    <p:dataTable var="packagePurchased" value="#{stakeholderManagerBean.nextServicePackage}">
                        <p:column headerText="Name">
                            <h:outputText value="#{packagePurchased.servicePackage.name}" />
                        </p:column>

                        <p:column headerText="Description">
                            <h:outputText value="#{packagePurchased.servicePackage.description}" />
                        </p:column>

                        <p:column headerText="Price">
                            <h:outputText value="#{packagePurchased.price}" />
                        </p:column>

                        <p:column headerText="Date Begin">
                            <h:outputText value="#{stakeholderManagerBean.getFormatDate(packagePurchased.datePurchased)}" />
                        </p:column>
                        <p:column headerText="Date Expired">
                            <h:outputText value="#{stakeholderManagerBean.getFormatDate(packagePurchased.dateExpired)}" />
                        </p:column>
                    </p:dataTable>
                </h:panelGrid>
                <p:accordionPanel autoHeight="false">
                    <p:tab title="Buy new Package">
                        <h:outputLabel for="blank" style="font-weight: bold" value=""/>
                        <p:dataTable var="servicePackage" value="#{stakeholderManagerBean.servicePackages}" selection="#{stakeholderManagerBean.selectedServicePackage}" paginator="true" rows="10">
                            <p:column selectionMode="single" />

                            <p:column headerText="Name">
                                <h:outputText value="#{servicePackage.name}" />
                            </p:column>

                            <p:column headerText="Description">
                                <h:outputText value="#{servicePackage.description}" />
                            </p:column>

                            <p:column headerText="Price">
                                <h:outputText value="#{servicePackage.price}" />
                            </p:column>
                        </p:dataTable>
                        <h:outputLabel for="blank" style="font-weight: bold" value=""/>
                        <p>
                            <h:outputLabel for="monthPurchased" style="font-weight: bold" value="Number of months purchased: " />
                            <h:selectOneMenu value="#{stakeholderManagerBean.numOfMonth}" id="noOfMonth">
                                <f:selectItem itemLabel="1" itemValue="1"></f:selectItem>
                                <f:selectItem itemLabel="2" itemValue="2"></f:selectItem>
                                <f:selectItem itemLabel="3" itemValue="3"></f:selectItem>
                                <f:selectItem itemLabel="4" itemValue="4"></f:selectItem>
                                <f:selectItem itemLabel="5" itemValue="5"></f:selectItem>
                                <f:selectItem itemLabel="6" itemValue="6"></f:selectItem>
                                <f:selectItem itemLabel="7" itemValue="7"></f:selectItem>
                                <f:selectItem itemLabel="8" itemValue="8"></f:selectItem>
                                <f:selectItem itemLabel="9" itemValue="9"></f:selectItem>
                                <f:selectItem itemLabel="10" itemValue="10"></f:selectItem>
                                <f:selectItem itemLabel="11" itemValue="11"></f:selectItem>
                                <f:selectItem itemLabel="12" itemValue="12"></f:selectItem>
                            </h:selectOneMenu>
                        </p>
                        <p>
                            <p:commandButton id="btn" value="Buy this service package" update="panel" actionListener="#{stakeholderManagerBean.branchPurchaseServicePackage}" />
                        </p>
                    </p:tab>

                    <p:tab title="Extend Current Package">
                        <p>
                            <h:outputLabel for="monthExtended" style="font-weight: bold" value="Number of months extended: " />
                            <h:selectOneMenu value="#{stakeholderManagerBean.numOfMonthExtend}" id="noOfMonthExtend">
                                <f:selectItem itemLabel="1" itemValue="1"></f:selectItem>
                                <f:selectItem itemLabel="2" itemValue="2"></f:selectItem>
                                <f:selectItem itemLabel="3" itemValue="3"></f:selectItem>
                                <f:selectItem itemLabel="4" itemValue="4"></f:selectItem>
                                <f:selectItem itemLabel="5" itemValue="5"></f:selectItem>
                                <f:selectItem itemLabel="6" itemValue="6"></f:selectItem>
                                <f:selectItem itemLabel="7" itemValue="7"></f:selectItem>
                                <f:selectItem itemLabel="8" itemValue="8"></f:selectItem>
                                <f:selectItem itemLabel="9" itemValue="9"></f:selectItem>
                                <f:selectItem itemLabel="10" itemValue="10"></f:selectItem>
                                <f:selectItem itemLabel="11" itemValue="11"></f:selectItem>
                                <f:selectItem itemLabel="12" itemValue="12"></f:selectItem>
                            </h:selectOneMenu>
                        </p>
                        <p>
                            <p:commandButton id="btn1" value="Extend current service package" update="panel" actionListener="#{stakeholderManagerBean.branchExtendServicePackage}" />
                        </p>
                    </p:tab> 
                    <p:tab title="Terminate Current Package">
                        <p:commandButton id="btn2" value="Terminate current service package" update="panel" actionListener="#{stakeholderManagerBean.branchTerminateServicePackage}" />
                    </p:tab> 
                </p:accordionPanel> 
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>